#include "main/utils.h"
using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(string s) {
      int len = s.size();
      unordered_set<char> st;
      int ans = 0;
      int right = -1;
      for (int i = 0; i < len; ++i) {
        if (i != 0) {
          st.erase(s[i - 1]);
        }
        while (right + 1 < len && st.count(s[right + 1]) == 0) {
          st.insert(s[right + 1]);
          ++right;
        }
        ans = max(ans, (right - i + 1));
      }
      return ans;
    }
};

int main() {
  string input = "abcabcbb";
  Solution su;
  cout << su.lengthOfLongestSubstring(input) << endl;
}
